<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
    <title>新增宠物信息- 萌迹(Cute Trial Admin)后台管理系统</title>
    <link rel="icon" href="petvet.ico" type="image/ico">
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="css/materialdesignicons.min.css" rel="stylesheet">
    <!--标签插件-->
    <link rel="stylesheet" href="js/jquery-tags-input/jquery.tagsinput.min.css">
    <link href="css/style.min.css" rel="stylesheet">
</head>

<body>
<div class="container-fluid p-t-15">

    <div class="row">
        <div class="col-lg-12">
            <div class="card">
                <div class="card-body">

                    <form action="#!" method="post" class="row">
                        <div class="form-group col-md-12">
                            <label for="petName">宠物姓名</label>
                            <input type="text" class="form-control" id="petName" name="petName" value=""
                                   placeholder=""/>
                        </div>
                        <div class="form-group col-md-12">
                            <label for="petType">宠物品种</label>
                            <input type="text" class="form-control" id="petType" name="petType" value=""
                                   placeholder=""/>
                        </div>
                        <div class="form-group col-md-12">
                            <label for="petGender">性别</label>
                            <input type="text" class="form-control" id="petGender" name="petGender" value=""
                                   placeholder="公/母"/>
                        </div>
                        <div class="form-group col-md-12">
                            <label for="petAge">年龄</label>
                            <input type="text" class="form-control" id="petAge" name="petAge" value="" placeholder=""/>
                        </div>
                        <div class="form-group col-md-12">
                            <label for="birthAge">出生日期</label>
                            <input type="text" class="form-control" id="birthAge" name="birthAge" value=""
                                   placeholder="xxxx-yy-zz"/>
                        </div>
                        <div class="form-group col-md-12">
                            <label for="neutered">绝育状态</label>
                            <input type="text" class="form-control" id="neutered" name="neutered" value=""
                                   placeholder="1-已绝育/0-未绝育"/>
                        </div>
                        <div class="form-group col-md-12">
                            <label for="ownerId">主人信息</label>
                            <input type="text" class="form-control" id="ownerId" name="ownerId" value=""
                                   placeholder=""/>
                        </div>
                        <div class="form-group col-md-12">
                            <label for="remark">状态</label>
                            <input type="text" class="form-control" id="remark" name="remark" value=""
                                   placeholder=""/>
                        </div>
                        <div class="form-group col-md-12">
                            <button type="button" onclick="addPetInfo()" class="btn btn-primary ajax-post"
                                    target-form="add-form">确 定
                            </button>
                            <button type="button" class="btn btn-default"
                                    onclick="javascript:history.back(-1);return false;">返 回
                            </button>
                        </div>
                    </form>

                </div>
            </div>
        </div>

    </div>

</div>

<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<!--标签插件-->
<script src="js/jquery-tags-input/jquery.tagsinput.min.js"></script>
<script type="text/javascript" src="js/main.min.js"></script>
<script type="text/javascript">
    <!--
    定义添加方法-->
    function addPetInfo() {
        <!-- 封装提交参数 -->
        var params = {
            "petName": $("#petName").val(),
            "petType": $("#petType").val(),
            "petGender": $("#petGender").val(),
            "petAge": $("#petAge").val(),
            "birthAge": $("#birthAge").val(),
            "neutered": $("#neutered").val(),
            "ownerId": $("#ownerId").val(),
            "remark": $("#remark").val()
        };


        <!--添加用户信息-->
        /*$.getJSON("petInfo/add", params,
            function (riv) {
                if (riv.code === 1) {
                    alert("添加成功");
                    location.href = "pet_id.html";
                } else {
                    alert(riv.msg);
                }
            });*/
        $.ajax({
            type: "POST",
            url: "petInfo/add",
            data: JSON.stringify(params),
            dataType: "json",
            success: function (riv) {
                if (riv.code === 1) {
                    alert("添加成功");
                    location.href = "pet_id.html";
                } else {
                    alert(riv.msg);
                }
            }
        });
    }
</script>
</body>
</html>